package com.kotlinvben.exception


/**
 * 用户相关异常
 */
sealed class UserException(
    override val code: Int,
    override val message: String
) : BusinessException(code, message) {
    companion object {
        const val USER_NOT_FOUND = 1001
        const val USER_DISABLED = 1002
        const val INVALID_CREDENTIALS = 1003
        const val USERNAME_ALREADY_EXISTS = 1004
        const val EMAIL_ALREADY_EXISTS = 1005
        const val PHONE_ALREADY_EXISTS = 1006
    }
}

/**
 * 用户不存在异常
 */
class UserNotFoundException : UserException(
    code = USER_NOT_FOUND,
    message = "用户不存在"
)

/**
 * 用户已禁用异常
 */
class UserDisabledException : UserException(
    code = USER_DISABLED,
    message = "用户已被禁用"
)

/**
 * 用户名或密码错误异常
 */
class InvalidCredentialsException : UserException(
    code = INVALID_CREDENTIALS,
    message = "用户名或密码错误"
)

/**
 * 用户名已存在异常
 */
class UsernameAlreadyExistsException : UserException(
    code = USERNAME_ALREADY_EXISTS,
    message = "用户名已存在"
)

/**
 * 邮箱已存在异常
 */
class EmailAlreadyExistsException : UserException(
    code = EMAIL_ALREADY_EXISTS,
    message = "邮箱已存在"
)

/**
 * 手机号已存在异常
 */
class PhoneAlreadyExistsException : UserException(
    code = PHONE_ALREADY_EXISTS,
    message = "手机号已存在"
) 